<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="renderer" content="webkit">
<title><{:C("WEB_TITLE")}></title>
<link rel="shortcut icon" href="favicon.ico">
<link href="/Public/Front/css/bootstrap.min.css" rel="stylesheet">
<link href="/Public/Front/css/font-awesome.min.css" rel="stylesheet">
<link href="/Public/Front/css/animate.css" rel="stylesheet">
<link href="/Public/Front/css/style.css" rel="stylesheet">
<link rel="stylesheet" href="/Public/Front/js/plugins/layui/css/layui.css"  media="all">
<style>
.layui-form-switch {width:54px;}
</style>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>接口供应商管理</h5>
						<div class="row">
							<div class="col-sm-2 pull-right">
								<a href="javascript:;" id="addSupplier" class="layui-btn">添加供应商</a>
							</div>
                        </div>
                    </div>
                    <div class="ibox-content">
                        
                        <div class="table-responsive">
                            <table class="table table-hover">
                                <thead>
                                    <tr>

                                        <th>编号</th>
                                        <th>接口名称</th>
                                        <th>接口代码</th>
										<th>类型</th>
										<th>结算类型</th>
										<th>分流比例</th>
                                        <th>接口状态</th>
										<th>费率下限</th>
										<th>费率上限</th>
										<th>一键切换通道</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
								<volist name="list" id="p">
                                    <tr>
                                        <td><{$p.id}></td>
                                        <td><{$p.title}></td>
                                        <td><{$p.code}></td>
										<td><{$p[paytype]|getPaytype}></td>
										<td><{$p.channel_type}></td>
										<td><{$p.diversion}></td>
                                        <td>
											<div class="layui-form">
											<input type="checkbox" <if condition="$p['status']">checked</if> name="status" value="1" data-id="<{$p.id}>" data-name="<{$p.title}>" lay-skin="switch" lay-filter="switchTest" lay-text="开启|关闭">
											</div>
										</td>
										<td><span id="dfRate<{$p.id}>"><{$p.defaultrate}></span></td>
										<td><span id="fdRate<{$p.id}>"><{$p.fengding}></span></td>
                                        <td><a href="<{:U('Channel/switchAllChannel', array('pid' => $p[id]))}>" class="layui-btn layui-btn-small"  >切换全部</a></td>
                                        <td>
											<div class="layui-btn-group">
                                              <a href="<{:U('Channel/account', array('pid' => $p[id]))}>" class="layui-btn layui-btn-small"  >子账户</a>
											  <button class="layui-btn layui-btn-small" onclick="admin_editRate('编辑费率','<{:U('Channel/editRate',array('pid'=>$p[id]))}>')">费率</button>
											  <button class="layui-btn layui-btn-small" onclick="admin_edit('编辑供应商接口','<{:U('Channel/editSupplier',array('pid'=>$p[id]))}>')">编辑</button>
											  <button class="layui-btn layui-btn-small" onclick="admin_del(this,'<{:$p[id]}>')">删除</button>
											</div>
                                        </td>
                                    </tr>
                                </volist>    
                                </tbody>
                            </table>
                        </div>
						<div class="page"><{$page}></div>
                    </div>
                </div>
            </div>

        </div>
    </div>

    <script src="/Public/Front/js/jquery.min.js"></script>
    <script src="/Public/Front/js/bootstrap.min.js"></script>
    <script src="/Public/Front/js/plugins/peity/jquery.peity.min.js"></script>
    <script src="/Public/Front/js/content.js"></script>
	<script src="/Public/Front/js/plugins/layui/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
layui.use(['layer', 'form'], function(){
  var form = layui.form
  ,layer = layui.layer;
  
  //监听指定开关
  form.on('switch(switchTest)', function(data){
	var pid = $(this).attr('data-id'),
	isopen = this.checked ? 1 : 0,
	title = $(this).attr('data-name');
	$.ajax({
		url:"<{:U('Channel/editStatus')}>",
		type:'post',
		data:"pid="+pid+"&isopen="+isopen,
		success:function(res){
			if(res.status){
				layer.tips('温馨提示：'+title+'开启', data.othis);
			}else{
				layer.tips('温馨提示：'+title+'关闭', data.othis);
			}
		}
	});
  });
  
  //监听提交
  $('#addSupplier').on('click',function(){
	var w=640,h;
	if (h == null || h == '') {
		h=($(window).height() - 50);
	};
	layer.open({
		type: 2,
		fix: false, //不固定
		maxmin: true,
		shadeClose: true,
		area: [w+'px', h +'px'],
		shade:0.4,
		title: "添加供应商",
		content: "<{:U('Channel/addSupplier')}>"
	});
  });
});
 //编辑
 function admin_edit(title,url){
	var w=600,h;
	if (h == null || h == '') {
		h=($(window).height() - 50);
	};
	layer.open({
		type: 2,
		fix: false, //不固定
		maxmin: true,
		shadeClose: true,
		area: [w+'px', h +'px'],
		shade:0.4,
		title: title,
		content: url
	});
 }
 /*删除*/
function admin_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			url:"<{:U('Channel/delSupplier')}>",
			type:'post',
			data:'pid='+id,
			success:function(res){
				if(res.status){
				$(obj).parents("tr").remove();
				layer.msg('已删除!',{icon:1,time:1000});
				}
			}
		});
	});
}
/*费率*/
function admin_editRate(title,url){
	var w=510,h=320;
	if (h == null || h == '') {
		h=($(window).height() - 50);
	};
	layer.open({
		type: 2,
		fix: false, //不固定
		maxmin: true,
		shadeClose: true,
		area: [w+'px', h +'px'],
		shade:0.4,
		title: title,
		content: url
	});
  }
</script>
</body>
</html>
